package dialogs;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import utility.SelectAllWhenGainFocus;

public class ConnectionPanel extends JPanel {
	private JPanel nullPanel = null;
	private JLabel sourceLabel = null;
	private JLabel userLabel = null;
	private JLabel portLabel = null;
	private JLabel passwordLabel = null;
	private JTextField sourceTextField = null;
	private JTextField userTextField = null;
	private JTextField portTextField = null;
	private JPasswordField passwordField = null;
	private SelectAllWhenGainFocus focusHandler = null;

	/**
	 * This is the default constructor
	 */
	public ConnectionPanel() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
		gridBagConstraints21.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated
		gridBagConstraints21.gridy = 3; // Generated
		gridBagConstraints21.weightx = 1.0; // Generated
		gridBagConstraints21.insets = new java.awt.Insets(0, 0, 3, 5); // Generated
		gridBagConstraints21.gridx = 1; // Generated
		GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
		gridBagConstraints11.gridx = 0; // Generated
		gridBagConstraints11.anchor = java.awt.GridBagConstraints.EAST; // Generated
		gridBagConstraints11.insets = new java.awt.Insets(0, 6, 5, 3); // Generated
		gridBagConstraints11.gridy = 3; // Generated
		portLabel = new JLabel();
		portLabel.setText("Port"); // Generated
		GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
		gridBagConstraints6.gridx = 0; // Generated
		gridBagConstraints6.weightx = 0.0D; // Generated
		gridBagConstraints6.weighty = 1000.0D; // Generated
		gridBagConstraints6.gridwidth = 2; // Generated
		gridBagConstraints6.ipadx = 0; // Generated
		gridBagConstraints6.fill = java.awt.GridBagConstraints.BOTH; // Generated
		gridBagConstraints6.gridy = 4; // Generated
		GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
		gridBagConstraints5.insets = new java.awt.Insets(6, 6, 5, 3); // Generated
		gridBagConstraints5.anchor = java.awt.GridBagConstraints.EAST; // Generated
		GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
		gridBagConstraints4.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated
		gridBagConstraints4.gridy = 2; // Generated
		gridBagConstraints4.weightx = 10.0; // Generated
		gridBagConstraints4.insets = new java.awt.Insets(0, 0, 3, 5); // Generated
		gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST; // Generated
		gridBagConstraints4.ipadx = 0; // Generated
		gridBagConstraints4.gridx = 1; // Generated
		GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
		gridBagConstraints3.gridx = 0; // Generated
		gridBagConstraints3.insets = new java.awt.Insets(0, 6, 5, 3); // Generated
		gridBagConstraints3.anchor = java.awt.GridBagConstraints.EAST; // Generated
		gridBagConstraints3.gridy = 2; // Generated
		passwordLabel = new JLabel();
		passwordLabel.setText("Password"); // Generated
		GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
		gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated
		gridBagConstraints2.gridy = 1; // Generated
		gridBagConstraints2.weightx = 10.0; // Generated
		gridBagConstraints2.insets = new java.awt.Insets(0, 0, 3, 5); // Generated
		gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; // Generated
		gridBagConstraints2.gridx = 1; // Generated
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
		gridBagConstraints1.gridx = 0; // Generated
		gridBagConstraints1.insets = new java.awt.Insets(0, 6, 5, 3); // Generated
		gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST; // Generated
		gridBagConstraints1.gridy = 1; // Generated
		userLabel = new JLabel();
		userLabel.setText("User"); // Generated
		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; // Generated
		gridBagConstraints.gridy = 0; // Generated
		gridBagConstraints.weightx = 10.0; // Generated
		gridBagConstraints.insets = new java.awt.Insets(6, 0, 3, 5); // Generated
		gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; // Generated
		gridBagConstraints.gridx = 1; // Generated
		sourceLabel = new JLabel();
		sourceLabel.setText("Source"); // Generated
		this.setLayout(new GridBagLayout()); // Generated
		this.setSize(300, 107);
		this.add(sourceLabel, gridBagConstraints5); // Generated
		this.add(getSourceTextField(), gridBagConstraints); // Generated
		this.add(userLabel, gridBagConstraints1); // Generated
		this.add(getUserTextField(), gridBagConstraints2); // Generated
		this.add(passwordLabel, gridBagConstraints3); // Generated
		this.add(getPasswordField(), gridBagConstraints4); // Generated
		this.add(getNullPanel(), gridBagConstraints6); // Generated
		this.add(portLabel, gridBagConstraints11); // Generated
		this.add(getPortTextField(), gridBagConstraints21); // Generated
	}

	/**
	 * This method initializes serverTextField
	 * 
	 * @return javax.swing.JTextField
	 */
	protected JTextField getSourceTextField() {
		if (sourceTextField == null) {
			sourceTextField = new JTextField();
			sourceTextField.setText("mantis"); // Generated
			sourceTextField.addFocusListener(this.getFocusHandler());
		}
		return sourceTextField;
	}

	/**
	 * This method initializes userTextField
	 * 
	 * @return javax.swing.JTextField
	 */
	protected JTextField getUserTextField() {
		if (userTextField == null) {
			userTextField = new JTextField();
			userTextField.setText("root"); // Generated
			userTextField.addFocusListener(this.getFocusHandler());
		}
		return userTextField;
	}

	/**
	 * This method initializes passwordField
	 * 
	 * @return javax.swing.JPasswordField
	 */
	protected JPasswordField getPasswordField() {
		if (passwordField == null) {
			passwordField = new JPasswordField();
			passwordField.setText("china"); // Generated
			passwordField.addFocusListener(this.getFocusHandler());
		}
		return passwordField;
	}

	/**
	 * This method initializes nullPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getNullPanel() {
		if (nullPanel == null) {
			nullPanel = new JPanel();
		}
		return nullPanel;
	}

	/**
	 * This method initializes portTextField
	 * 
	 * @return javax.swing.JTextField
	 */
	protected JTextField getPortTextField() {
		if (portTextField == null) {
			portTextField = new JTextField();
			portTextField.setText("3306"); // Generated
			portTextField.addFocusListener(this.getFocusHandler());
		}
		return portTextField;
	}

	public void disablePort() {
		this.portLabel.setEnabled(false);
		this.portTextField.setEnabled(false);
	}

	private SelectAllWhenGainFocus getFocusHandler() {
		if (null == focusHandler)
			focusHandler = new SelectAllWhenGainFocus();
		return focusHandler;
	}
} // @jve:decl-index=0:visual-constraint="82,115"
